import {Component, OnInit} from '@angular/core';
import {VersionInfo} from './home.data';
import {TranslateService} from '@ngx-translate/core';
import {HomeService} from './home.service';
import {BaseComponent} from '../basic/commons/base.component';
import {ConfirmationService, MessageService} from 'primeng/api';

@Component({
    selector: 'home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.scss']
})
export class HomeComponent extends BaseComponent implements OnInit {

    base: VersionInfo = <VersionInfo> {majorVersion: '', buildVersion: '', releaseTime: ''};
    constructor(
        private homeService: HomeService,
        protected messageService: MessageService,
        protected confirmationService: ConfirmationService,
        protected translate: TranslateService) {
        super(messageService, confirmationService, translate);
    }

    ngOnInit() {
        this.homeService.getVersion().then(resp => {
            if (!resp.success) {
                alert(resp.errorMessage);
                return;
            }
            this.base = resp.data;
        });
    }

}
